package com.gjy.batch;

import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

/**
 * @author gjy
 * @version 1.0
 * @since 2025-07-03 08:35:19
 */
@SpringBootApplication
public class BatchApp {

    public static void main(String[] args) {
        SpringApplication.run(BatchApp.class, args);
    }

    @Bean
    public CommandLineRunner runStudentJob(JobLauncher jobLauncher,
                                           Job importStudentJob) {
        return args -> {
            JobParameters params = new JobParametersBuilder()
                    .addLong("startAt", System.currentTimeMillis())
                    .toJobParameters();
            jobLauncher.run(importStudentJob, params);
        };
    }
}
